auto();
device.keepScreenOn();
var f=rawInput("发布第几个视频","");
var b=rawInput("关注抖音的关键字","");
launchApp("抖音短视频");
sleep("3000");
setScreenMetrics(1080,1920);
sleep("1000");
 click(550,1733);
 sleep(2000);
 click("相册");
 sleep(3000);
 if(f==1){
 click(494, 913);
 }else if(f==2){
        click(223, 913);
    }else if(f==3){
            click(1036, 641);
        }else if(f==4){
                click(766, 641);
            }else if(f==5){
                    click(494, 641);
                }else if(f==6){
                        click(223, 641);
                    }else if(f==7){
                            click(1036, 372);
                        }else if(f==8){
                                click(766, 372);
                            }else if(f==9){
                                    click(494, 372);
                                }else if(f==10){
                                        click(223, 372);
                                    }else {
                                            toastLog("没有这个视频");
 }
 sleep(3000);
 click("下一步");
 sleep(3000);
 click("下一步");
 sleep(60000);
 click("下一步");
 sleep(2000);
 click(276, 276);
var txt=files.open("/sdcard/1.txt"); 
var arr=txt.readlines();
toastLog("当前文件存在"+arr.length+"条数据");
txt=arr[f-1]   
sleep(2000)
setText(txt) 
 sleep(5000);
 click(379, 692);
 sleep(2000);
 back();
sleep(2000);
click("发布");
sleep(30000);   //上传结束



click("我");//988, 1766
 sleep(4000);
 click("朋友");//988, 1766
 sleep(2000);
 click(264, 236);//搜索框
 sleep(3000);
 setText(b);
 sleep(2000);
 click("搜索");//搜索1009, 252
 click(499, 388);//点进去朋友里新号设置时间一小时以上点关注(958, 388)
 sleep(2000);
 var a=text("粉丝").findOne(5000)
if(a!=null){
   let xy= a.bounds()
   click(xy.centerX(),xy.centerY())
}else{
    toastLog("找不到节点")
}
 sleep(3000);
 for(var c=1;true;c++){
 var target =  text("关注").findOnce() || text("回关").findOnce();
  if (target == null) {
swipe(device.width/622,1768,device.width/542,222,860);
}
     else
     target.click();
    sleep(10000);
if(c==30)
{ break;}
}   
sleep(2000);
 back();
sleep(2000);
 back();
sleep(2000);
 back();
sleep(2000);
 back();
sleep(2000);//关注结束



text("朋友").waitFor()
toastLog('抖音界面,延迟3秒')
sleep(5000)
for (let index = 0; index < 60; index++) {
    swipe(device.width - 200, device.height - 500, device.width - 200, device.height / 5, 500)
    sleep(8000)
    let btn = descContains("喜欢").className("android.widget.ImageView").boundsInside(0, device.height * 0.1, device.width, device.height * 0.9).findOne(5000)
    if (btn) {
        if (btn.desc().match("未选中")) {
            btn.parent().click()
        }
        if (btn.desc().match("已选中")) {
            toastLog('已经点赞过')
        }
    } else {
        toastLog("未找到点赞按钮")

    }
    sleep(3000)
}

click("我");//988, 1766
 sleep(4000);
 click("朋友");//988, 1766
 sleep(3000);
 setText(b);
 sleep(2000);
 click("搜索");//搜索1009, 252
 sleep(3000);
 click(958, 388);
 sleep(1*1*1000);    //新号设置时间一小时以上
 click(499, 388);//点进去朋友里
 sleep(2000);
 var a=text("粉丝").findOne(5000)
if(a!=null){
   let xy= a.bounds()
   click(xy.centerX(),xy.centerY())
}else{
    toastLog("找不到节点")
}
 sleep(3000);
 for(var c=1;true;c++){
 var target =  text("关注").findOnce() || text("回关").findOnce();
  if (target == null) {
swipe(device.width/622,1768,device.width/542,222,860);
}
     else
     target.click();
    sleep(10000);
if(c==30)
{ break;}
}   
sleep(2000);
 back();
sleep(2000);
 back();
sleep(2000);
 back();
sleep(2000);
 back();
sleep(2000);//关注结束



text("朋友").waitFor()
toastLog('抖音界面,延迟3秒')
sleep(3000)
for (let index = 0; index < 200; index++) {
    swipe(device.width - 200, device.height - 500, device.width - 200, device.height / 5, 500)
    sleep(8000)
auto.setWindowFilter(function(window){
    return true;
});
let btn = descContains("喜欢").className("android.widget.ImageView").boundsInside(0, device.height * 0.1, device.width, device.height * 0.9).findOne(1000)   //934,840,1065,971
log(btn)
if (btn!=null) {
    if (btn.desc().indexOf("未选中")>-1) {  //0, device.height * 0.1, device.width, device.height * 0.9
        if(btn.desc().indexOf("w")>-1){
            toastLog("当前点赞数量过万")
            btn.parent().click()
        }else{
            toastLog("当前点赞数量不过万")
        }
    }
    if (btn.desc().indexOf("已选中")>-1) {
        toastLog('已经点赞过')
    }
} else {
    toastLog("未找到点赞按钮")
}
}